<template>
    <div class="iscInfoWrap">
      <div class="head">
        <p class="colCLas"></p>
        <p class="info"></p>
      </div>

      <el-row>
        <el-form
            :inline="true"
            :model="searchParams"
            style="width: 100%"
            size="small"
            class="formInline"
        >
          <el-form-item label="汇总月份：" style="max-width: 340px">
            <el-date-picker type="month"  value-format="yyyy-MM" placeholder="选择日期" v-model="searchParams.month1" style="width: 100%;"></el-date-picker>
          </el-form-item>

          <el-button @click="getList" type="primary">查询汇总确认信息</el-button>
          <el-button @click="uploadIsc" type="primary">上传汇总确认信息</el-button>
          <el-button @click="cancelIsc" type="primary" >取消汇总确认</el-button>

        </el-form>
      </el-row>
      <el-row>
        <span style="margin-right: 20px;color: #07b9b9">发票汇总信息：</span>
      </el-row>
      <el-row>
        <el-table
          :data="comTableData"
          border
          style="width: 100%">
        <el-table-column
            prop="name"
            label="汇总项目"
            width="180">
        </el-table-column>
        <el-table-column
            prop="comData"
            label="企业端"
            width="180">
        </el-table-column>
        <el-table-column
            prop="lqData"
            label="税局端">
        </el-table-column>
      </el-table>
      </el-row>
      <el-row>
        <span style="margin-right: 20px;color: #07b9b9">发票详情信息</span>
          <el-button @click="exportExecl" type="primary">导出</el-button>
      </el-row>
      <tableList
          :data="listDetails"
          border
          :heightMin="130"
          :loading="loading"
          :keySet="keySet"
          :autoHeight="true"
          :tableData="listDetails"
          :paginationShow="true"
          :pageNumber="pages.current"
          :pageSize="pages.size"
          :total="pages.total"
          @handleSizeChange="handleSizeChange"
          @handleCurrentChange="handleCurrentChange"
      >

      </tableList>
    </div>

</template>
  
  <script>

import tableList from "@/components/tableList/index.vue";
import mixinTable from "@/mixin/mtable";
import {cancelIsc, exportExecl,uploadIsc, pageInvoice, queryIscInfomationPage} from "@/api/invoiceSummryConfirm.js";

export default {
    name: 'invoiceSummryConfirm',
    components:{
      //
      tableList
    },
    mixins: [mixinTable],
    created(){
      //this.getList()
    },
    data() {
      return {
        loading: false,
        listDetails: [],
        vmsIscInformationComVo:{},//企业端-暂时没用到
        vmsIscInformationLqVo: {},//税局端-暂时没用到
        blueInvoiceCount: 0,//蓝字发票数量
        blueInvoiceAmount: 0,//蓝字发票金额
        blueInvoiceTax: 0,//蓝字发票税额
        redInvoiceCount: 0,//红字发票数量
        redInvoiceAmount: 0,//红字发票金额
        redInvoiceTax: 0,//红字发票税额
        lqblueInvoiceCount: 0,//乐企蓝字发票数量
        lqblueInvoiceAmount: 0,//乐企蓝字发票金额
        lqblueInvoiceTax: 0,//乐企蓝字发票税额
        lqredInvoiceCount: 0,//乐企红字发票数量
        lqredInvoiceAmount: 0,//乐企红字发票金额
        lqredInvoiceTax: 0,//乐企红字发票税额

        // ''
        keySet: [
          {
            label: '发票状态',
            englishName: 'fpzt',
            width: '200px'
          },
          {
            label: '发票号码',
            englishName: 'fphm',
            width: '200px'
          },
          {
            label: '发票类型',
            englishName: 'fppz',
            width: '100px'
          },
          {
            label: '购买方名称',
            englishName: 'gmfmc',
            width: '100px'
          },
          {
            label: '金额',
            englishName: 'hjje',
            width: '100px'
          },
          {
            label: '税额',
            englishName: 'hjse',
            width: '200px'
          },
          {
            label: '价税合计',
            englishName: 'jshj',

          },

        ],
        comTableData:[
          {
            name: '蓝字发票数量',
            comData: this.blueInvoiceCount,
            lqData: '222'
          },
          {
            name: '蓝字发票金额',
            comData: this.blueInvoiceAmount,
            lqData: '222'
          },
          {
            name: '蓝字发票税额',
            comData: this.blueInvoiceTax,
            lqData: '222'
          },
          {
            name: '红字发票数量',
            comData: this.redInvoiceCount,
            lqData: '222'
          },
          {
            name: '红字发票金额',
            comData: this.redInvoiceAmount,
            lqData: '222'
          },
          {
            name: '红字发票税额',
            comData: this.redInvoiceTax,
            lqData: '222'
          }
        ],
      }
    },
    methods:{
      exportExecl() {
       exportExecl({
          month: this.searchParams.month1,
        })

      },

      /**
       *
       */
      async cancelIsc(){
        this.loading = true
        let params ={
          month:this.searchParams.month1,
          lzfpsl: this.blueInvoiceCount,//蓝字发票数量
          lzfpje: this.blueInvoiceAmount,//蓝字发票金额
          lzfpse: this.blueInvoiceTax,//蓝字发票税额
          hzfpsl: this.redInvoiceCount,//红字发票数量
          hzfpje: this.redInvoiceAmount,//红字发票金额
          hzfpse: this.redInvoiceTax,//红字发票税额
        }
        let {data, code, message} = await cancelIsc(params)
        this.loading = false
      },
      /**
       *
       */

      async uploadIsc(){
        this.loading = true
        let params ={
          month:this.searchParams.month1,
          lzfpsl: this.blueInvoiceCount,//蓝字发票数量
          lzfpje: this.blueInvoiceAmount,//蓝字发票金额
          lzfpse: this.blueInvoiceTax,//蓝字发票税额
          hzfpsl: this.redInvoiceCount,//红字发票数量
          hzfpje: this.redInvoiceAmount,//红字发票金额
          hzfpse: this.redInvoiceTax,//红字发票税额
        }
        let {data, code, message} = await uploadIsc(params)
        this.loading = false
        if (code == 200) {

        }
      },
      /**
       * 点击分页按钮查询当前页发票数据
       */
      handleCurrentChange(val){
        this.pages.current = val;
        this.getDetailPage()
      },
      handleSizeChange(val){
        this.pages.current = 1;
        this.pages.size = val;
        this.getDetailPage()
      },
      //获取分页数据，这里必须是异步，否则数据拿不到
      async getDetailPage(){
        this.loading = true
        let {data, code, message} = await pageInvoice({
          month: this.searchParams.month1,
          pageNo: this.pages.current,
          pageSize: this.pages.size,
        })
        if (code == 200) {
          this.loading = false
          this.listDetails = data.records
          this.pages.total = data.total
          this.pages.current = data.current
          this.pages.size = data.size
        } else {
          this.loading = false
          this.$message({
            type: 'error',
            message: message,
          })
          return false;
        }
      },
      /**
       * 查询列表数据
       * @param params
       * @returns {Promise<void>}
       */

      async getList() {
        this.loading = true
        let {data, code, message} = await queryIscInfomationPage({
          month: this.searchParams.month1,
          pageNo: this.pages.current,
          pageSize: this.pages.size,
        })
        if (code == 200) {
          this.loading = false
          this.comTableData[0].comData = data.vmsIscInformationComVo.blueInvoiceCount
          this.comTableData[1].comData = data.vmsIscInformationComVo.blueInvoiceAmount
          this.comTableData[2].comData = data.vmsIscInformationComVo.blueInvoiceTax
          this.comTableData[3].comData = data.vmsIscInformationComVo.redInvoiceCount
          this.comTableData[4].comData = data.vmsIscInformationComVo.redInvoiceAmount
          this.comTableData[5].comData = data.vmsIscInformationComVo.redInvoiceTax
          this.comTableData[0].lqData = data.vmsIscInformationLqVo.blueInvoiceCount
          this.comTableData[1].lqData = data.vmsIscInformationLqVo.blueInvoiceAmount
          this.comTableData[2].lqData = data.vmsIscInformationLqVo.blueInvoiceTax
          this.comTableData[3].lqData  = data.vmsIscInformationLqVo.redInvoiceCount
          this.comTableData[4].lqData  = data.vmsIscInformationLqVo.redInvoiceAmount
          this.comTableData[5].lqData = data.vmsIscInformationLqVo.redInvoiceTax
          this.listDetails = data.vmsIscInformationDetailVo.records
          this.pages.total = data.vmsIscInformationDetailVo.total
          this.pages.current = data.vmsIscInformationDetailVo.current
          this.pages.size = data.vmsIscInformationDetailVo.size
        } else {
          this.loading = false
          return false;
        }

      }
    }
}
</script>
  <style lang = "scss" scoped>
  @import '@/style/variables.scss';
  .el-row {
    margin-bottom: 30px;

  }
  .epsInfoWrap {
    box-sizing: border-box;
    .head {
      display: flex;
      height: 18px;
      align-items: center;
      margin-bottom: 4px;
      margin-top: 4px;
    }
  }

</style>
  